﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<script type="text/javascript">
    var currRowId = 0;
    var isJump = false;
    $(function () {
        initControl();
        gridList();
    });
    function initControl() {
        initBindSelect("#form1");
    }
    function gridList() {
        var $gridList = $("#gridList");
        $gridList.dataGrid({
            url: "/MainData/SupplierInfo/GetSupplierInfoJson",
            height: $(window).height() - 118,
            colModel: [
                { label: '供应商编码', name: 'UnitNO', width: 80, align: 'center', sortable: false, frozen: true },
                { label: '供应商全称', name: 'UnitFullName', width: 200, align: 'left', sortable: false, frozen: true },
                { label: '供应商简称', name: 'UnitShortName', width: 120, align: 'left', sortable: false, frozen: true },
                { label: '原供应商名称', name: 'UnitName', width: 200, align: 'left', sortable: false },
                { label: '更名时间', name: 'AlertNameTime', width: 80, align: 'center', sortable: false },
                { label: '检索码', name: 'SearchNO', width: 80, align: 'left', sortable: false },
                { label: '供应商地址', name: 'UnitAddress', width: 200, align: 'left', sortable: false },
                { label: '业务联系人', name: 'ContactUser', width: 80, align: 'left', sortable: false },
                { label: 'Email', name: 'ContactEMail', width: 120, align: 'left', sortable: false },
                { label: '电话', name: 'ContactPhone', width: 100, align: 'left', sortable: false },
                { label: '传真', name: 'ContactFax', width: 100, align: 'left', sortable: false },
                { label: '法人代表', name: 'LegalUser', width: 80, align: 'left', sortable: false },
                { label: 'Email', name: 'LegalEMail', width: 120, align: 'left', sortable: false },
                { label: '电话', name: 'LegalPhone', width: 100, align: 'left', sortable: false },
                { label: '传真', name: 'LegalFax', width: 100, align: 'left', sortable: false },
                { label: '委托代理人', name: 'EntrustUser', width: 80, align: 'left', sortable: false },
                { label: 'Email', name: 'EntrustEMail', width: 120, align: 'left', sortable: false },
                { label: '电话', name: 'EntrustPhone', width: 100, align: 'left', sortable: false },
                { label: '传真', name: 'EntrustFax', width: 100, align: 'left', sortable: false },
                { label: '运输部门电话', name: 'TransportPhone', width: 100, align: 'left', sortable: false },
                { label: '传真', name: 'TransportFax', width: 100, align: 'left', sortable: false },
                { label: 'Email', name: 'TransportEMail', width: 120, align: 'left', sortable: false },
                { label: '发运部门电话', name: 'ShippingPhone', width: 100, align: 'left', sortable: false },
                { label: '传真', name: 'ShippingFax', width: 100, align: 'left', sortable: false },
                { label: 'Email', name: 'ShippingEMail', width: 120, align: 'left', sortable: false },
                {
                    label: '是否材料需求', name: 'IsMaterial', width: 90, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否零件需求', name: 'IsCustomer', width: 90, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否材料供应商', name: 'IsMaterial', width: 100, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否零件供应商', name: 'IsProduct', width: 100, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否辅料供应商', name: 'IsAccessories', width: 100, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否容器供应商', name: 'IsFContainer', width: 100, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否模具厂家', name: 'IsMould', width: 90, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '设是否备厂家', name: 'Isdevice', width: 90, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '是否备件厂家', name: 'IsBJ', width: 90, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                {
                    label: '承运商', name: 'IsCarrier', width: 50, align: 'center', sortable: false, formatter: function (cellvalue, options, rowObject) {
                        return cellvalue == "1" ? "是" : "否";
                    }
                },
                { label: '单位性质', name: 'UniteNatureName', width: 80, align: 'center', sortable: false },
                { label: '单位类型', name: 'UniteTypeName', width: 80, align: 'center', sortable: false },
                { label: '产品类型', name: 'SupplierProductTypeName', width: 80, align: 'center', sortable: false },
                { label: '主供应类别', name: 'SupplyTypeName', width: 80, align: 'center', sortable: false },
                { label: '福田持股', name: 'UnitHolding', width: 80, align: 'center', sortable: false },
                { label: '北汽持股', name: 'DTHolding', width: 80, align: 'center', sortable: false },
                { label: '其他持股', name: 'DFYXHolding', width: 80, align: 'center', sortable: false },
                { label: '员工人数（人）', name: 'EmployeesNum', width: 80, align: 'center', sortable: false },
                { label: '固定资产(万元)', name: 'FixedAssets', width: 80, align: 'center', sortable: false },
                { label: '生产区面积(亩)', name: 'ProductionArea', width: 80, align: 'center', sortable: false },
                { label: '营业执照', name: 'BusinessLicense', width: 80, align: 'center', sortable: false },
                { label: '经营许可证', name: 'ExperiencePermits', width: 80, align: 'center', sortable: false },
                { label: '税务登记证', name: 'TaxRegistration', width: 80, align: 'center', sortable: false },
                { label: '法人代表证', name: 'LegalPermit', width: 80, align: 'center', sortable: false },
                { label: '特殊许可证', name: 'SpecialPermit', width: 80, align: 'center', sortable: false },
                { label: '主要用户', name: 'MajorUsers', width: 80, align: 'center', sortable: false },
                { label: '生产能力（件/年', name: 'ProductionCapacity', width: 80, align: 'center', sortable: false },
                { label: '配套时间', name: 'SupportingTime', width: 80, align: 'center', sortable: false },
                { label: '终止时间', name: 'TerminationTime', width: 80, align: 'center', sortable: false },
                { label: '电话', name: 'UnitPhone', width: 80, align: 'center', sortable: false },
                { label: '传真', name: 'UnitFax', width: 80, align: 'center', sortable: false },
                { label: 'EMAILE', name: 'UnitEMail', width: 80, align: 'center', sortable: false },
                { label: '近三年取得荣誉', name: 'ThreeHonor', width: 80, align: 'center', sortable: false },
                { label: '订货币种', name: 'CurrencyTypeName', width: 80, align: 'center', sortable: false },
                { label: '税号', name: 'UnitTariff', width: 80, align: 'center', sortable: false },
                { label: '开户银行', name: 'UnitBank1', width: 80, align: 'center', sortable: false },
                { label: '账号', name: 'UnitBankNO1', width: 80, align: 'center', sortable: false },
                { label: '开户银行', name: 'UnitBank2', width: 80, align: 'center', sortable: false },
                { label: '账号', name: 'UnitBankNO2', width: 80, align: 'center', sortable: false },
                { label: '开户银行', name: 'UnitBank3', width: 80, align: 'center', sortable: false },
                { label: '账号', name: 'UnitBankNO3', width: 80, align: 'center', sortable: false },
                { label: '开户银行', name: 'UnitBank4', width: 80, align: 'center', sortable: false },
                { label: '账号', name: 'UnitBankNO4', width: 80, align: 'center', sortable: false },
                { label: '主供产品类别', name: 'MainProductTypeName', width: 80, align: 'center', sortable: false },
                { label: '供应商状态', name: 'UnitStatusName', width: 80, align: 'center', sortable: false },
                { label: '主要采购方式', name: 'MainPurchaseTypeName', width: 80, align: 'center', sortable: false },
                { label: '供货级别', name: 'SupplyLevelName', width: 80, align: 'center', sortable: false },
                { label: '信誉等级', name: 'CreditLevelName', width: 80, align: 'center', sortable: false },
                { label: '开发手段', name: 'DevelopMeans', width: 80, align: 'center', sortable: false },
                { label: '开发周期', name: 'DevelopCycle', width: 80, align: 'center', sortable: false },
                { label: '工程师以上(人)', name: 'EngineersMore', width: 80, align: 'center', sortable: false },
                { label: '一般技师(人)', name: 'Engineers', width: 80, align: 'center', sortable: false },
                { label: '管理人员（人）', name: 'Management', width: 80, align: 'center', sortable: false },
                { label: '工人数量(人)', name: 'WorkersNum', width: 80, align: 'center', sortable: false },
                { label: '次上年产值(万元)', name: 'TimesPYearValue', width: 80, align: 'center', sortable: false },
                { label: '次上年利润(万元)', name: 'TimesPYearProfit', width: 80, align: 'center', sortable: false },
                { label: '本单位占比例(%)', name: 'UnitProportion1', width: 80, align: 'center', sortable: false },
                { label: '上年产值（万元）', name: 'TimesYearValue', width: 80, align: 'center', sortable: false },
                { label: '上年利润（万元）', name: 'TimesYearProfit', width: 80, align: 'center', sortable: false },
                { label: '本单位占比例(%)', name: 'UnitProportion2', width: 80, align: 'center', sortable: false },
                { label: '年销售额(万元)', name: 'UnitSales', width: 80, align: 'center', sortable: false },
                { label: '负责率(%)', name: 'DebtRatio', width: 80, align: 'center', sortable: false },
                { label: '分承包方合格标志', name: 'QualifiedMarkName', width: 80, align: 'center', sortable: false },
                { label: '分承包方维护日期', name: 'MaintainDate', width: 80, align: 'center', sortable: false },
                { label: '分承方包寄存记录', name: 'StorageRecord', width: 80, align: 'center', sortable: false },
                { label: '分承包方辅助说明', name: 'AssistExplain', width: 80, align: 'center', sortable: false },
                { label: '二方单位认证', name: 'UnitCertificationName', width: 80, align: 'center', sortable: false },
                { label: '审核评分(分)', name: 'AuditScore', width: 80, align: 'center', sortable: false },
                { label: '计量等级', name: 'MeasureGradeName', width: 80, align: 'center', sortable: false },
                { label: '评价日期', name: 'EvaluateDate', width: 80, align: 'center', sortable: false },
                { label: '审核证书', name: 'AuditCertificate', width: 80, align: 'center', sortable: false },
                { label: '评价结论', name: 'EvaluateConclusionName', width: 80, align: 'center', sortable: false },
                { label: '评价计划', name: 'EvaluatePlan', width: 80, align: 'center', sortable: false },
                { label: '二方质量评价', name: 'QualityEvaluation', width: 80, align: 'center', sortable: false },
                { label: '实物评价', name: 'EvaluationItems', width: 80, align: 'center', sortable: false },
                { label: '评价说明', name: 'EvaluateExplain', width: 80, align: 'center', sortable: false },
                { label: 'IS09000标准', name: 'ISOStandard', width: 80, align: 'center', sortable: false },
                { label: 'IS09000公司', name: 'ISOUnit', width: 80, align: 'center', sortable: false },
                { label: 'IS09000日期', name: 'ISODate', width: 80, align: 'center', sortable: false },
                { label: 'QS9000标准', name: 'QSStandard', width: 80, align: 'center', sortable: false },
                { label: 'QS9000公司', name: 'QSUnit', width: 80, align: 'center', sortable: false },
                { label: 'QS9000日期', name: 'QSDate', width: 80, align: 'center', sortable: false },
                { label: '其他标准', name: 'OtherStandards', width: 80, align: 'center', sortable: false },
                { label: '其他公司', name: 'OtherUnit', width: 80, align: 'center', sortable: false },
                { label: '其他日期', name: 'OtherDate', width: 80, align: 'center', sortable: false },
                { label: '创建人员', name: 'FCreateBy', width: 80, align: 'left', sortable: false },
                { label: '创建日期', name: 'FCreateDate', width: 80, align: 'center', sortable: false },
                { label: '创建时间', name: 'FCreateTime', width: 80, align: 'center', sortable: false },
                { label: '更改人员', name: 'FUpdateBy', width: 80, align: 'left', sortable: false },
                { label: '更改日期', name: 'FUpdateDate', width: 80, align: 'center', sortable: false },
                { label: '更改时间', name: 'FUpdateTime', width: 80, align: 'center', sortable: false },
                { label: '', name: 'UnitID', width: 80, align: 'center', hidden: true },
                { label: '单位性质(隐藏)', name: 'UniteNature', width: 80, align: 'center', hidden: true },
                { label: '单位类型(隐藏)', name: 'UniteType', width: 80, align: 'center', hidden: true },
                { label: '产品类型(隐藏)', name: 'SupplierProductType', width: 80, align: 'center', hidden: true },
                { label: '主供应类别（隐藏）', name: 'SupplyType', width: 80, align: 'center', hidden: true },
                { label: '订货币种（隐藏）', name: 'CurrencyType', width: 80, align: 'center', hidden: true },
                { label: '主供产品类别(隐藏)', name: 'MainProductType', width: 80, align: 'center', hidden: true },
                { label: '供应商状态（隐藏）', name: 'UnitStatus', width: 80, align: 'center', hidden: true },
                { label: '主要采购方式（隐藏）', name: 'MainPurchaseType', width: 80, align: 'center', hidden: true },
                { label: '供货级别(隐藏)', name: 'SupplyLevel', width: 80, align: 'center', hidden: true },
                { label: '信誉等级(隐藏)', name: 'CreditLevel', width: 80, align: 'center', hidden: true },
                { label: '分承包方合格标志（隐藏）', name: 'QualifiedMark', width: 80, align: 'center', hidden: true },
                { label: '计量等级（隐藏）', name: 'MeasureGrade', width: 80, align: 'center', hidden: true },
                { label: '二方单位认证（隐藏）', name: 'UnitCertification', width: 80, align: 'center', hidden: true },
                { label: '评价结论（隐藏）', name: 'EvaluateConclusion', width: 80, align: 'center', hidden: true },
            ],
            pager: "#gridPager",
            sortname: 'UnitNO asc',
            viewrecords: true,  //是否显示行数
            rownumWidth: 40,
            gridComplete: function () {

            },
            loadComplete: function () {
                var rowDatas = $gridList.jqGrid("getRowData");
                var length = rowDatas.length + 1;
                if (length > 0) {
                    if (currRowId == 0) {
                        currRowId = 1;
                    } else if (currRowId > length) {
                        currRowId = length;
                    }
                }
                if (currRowId > 0) {
                    $gridList.jqGrid('setSelection', currRowId);
                    var $grid = $('#gview_gridList .ui-jqgrid-bdiv');
                    if (isJump) {
                        $grid.setScrollTop(length, currRowId);
                        isJump = false;
                    } else {
                        var top = $grid.scrollTop();
                        $grid.scrollTop(top + 1);
                    }
                }
            },
            onSelectRow: function (rowid) {
                currRowId = rowid;
                $('#btn_remove').removeClass("disabled");
                $('#btn_edit').removeClass("disabled");
            },
            onPaging: function (page_btn) {
                currRowId = 1;
            }
        });
        $gridList.jqGrid('setLabel', 0, '序号', 'rowNumberHeaderStyle');
        $gridList.jqGrid('setFrozenColumns');
        $("#btn_search").click(function () {
            reloadGrid();
        });
    }
    function reloadGrid(currNumber) {
        currNumber = currNumber || '';
        var currPage = 1;
        if (currNumber != "") {
            //var data = $("#form1").formSerialize();
            var data = {};
            var page = $('#gridList').getGridParam('page'); // current page
            var rows = $('#gridList').getGridParam('rowNum'); // rows
            var sidx = $('#gridList').getGridParam('sortname'); // sidx
            var sord = $('#gridList').getGridParam('sortorder'); // sord
            data["sidx"] = sidx;
            data["sord"] = sord;
            data["rows"] = rows;
            data["currNumber"] = currNumber;
            $.ajaxSetup({ async: false });
            $.getJSON("/MainData/SupplierInfo/GetSupplierInfoSortJson", data, function (result) {
                currPage = result.currPage;
                currRowId = result.currIndex;
            });
            $.ajaxSetup({ async: true });
            emptyDataById("#form1");
            isJump = true;
            $("#gridList").jqGrid('setGridParam', {
                page: currPage,
            }).trigger('reloadGrid');
        } else {
            isJump = false;
            $("#gridList").jqGrid('setGridParam', {
                postData: $("#form1").formSerialize(),
            }).trigger('reloadGrid');
        }
    }
    function btn_add() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/MainData/SupplierInfo/SupplierInfoInput"
        });
    }
    function btn_edit() {
        var rowData = $("#gridList").jqGrid('getRowData', currRowId);
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/MainData/SupplierInfo/SupplierInfoInput?status=U&number=" + rowData.UnitID
        });
    }
    function btn_remove() {
        var rowData = $("#gridList").jqGrid('getRowData', currRowId);
        $.modalConfirm("注：您确定要【删除】该条数据吗？", function (r) {
            if (r) {
                $.submitForm({
                    url: "/MainData/SupplierInfo/SubmitSupplierInfoForm?status=D",
                    param: { keyValue: rowData.UnitID },
                    success: function () {
                        reloadGrid();
                    }
                })
            }
        });
    }
    function btn_export() {
        var url = "/Common/ExcelExport?" + init_sql();
        location.href = url;
    }
    function init_sql() {
        var tablename = "V_ZSJ_B1_GH_SupplierInformation";
        var condition = "UseUnit='@FriendStar.Code.Configs.GetValue("UseUnit")'";
        var cols = [];
        //获取列字段
        var colModel = $("#gridList").jqGrid('getGridParam', 'colModel');
        for (var i = 0; i < colModel.length; i++) {
            var columnHidden = colModel[i].hidden;
            var columnName = colModel[i].name;
            var columnLabel = colModel[i].label;
            if (columnHidden == false && columnName != "rn" && columnName != "") {
                if (columnLabel != '') {
                    cols.push(columnName + ' [' + columnLabel + ']');
                } else {
                    cols.push(columnName);
                }
            }
        }
        if ($('#UnitNO').val() != '') {
            condition += " AND UnitNO LIKE '%" + $('#UnitNO').val() + "%'";
        }
        if ($('#UnitFullName').val() != '') {
            condition += " AND UnitFullName LIKE '%" + $('#UnitFullName').val() + "%'";
        }
        if ($('#UnitShortName').val() != '') {
            condition += " AND UnitShortName LIKE '%" + $('#UnitShortName').val() + "%'";
        }
        var sql = "SELECT " + cols.join(',') + " FROM " + tablename + " WHERE " + condition + " ORDER BY UnitNO ASC";
        return "sql=" + sql;
    }
</script>
<div id="layout" style="height: 100%; width: 100%;">
    <form id="form1">
        <div style="padding: 12px 0 5px 0; padding-left: 15px; border-bottom: 1px solid #ccc; " class="line-table input-width-140">
            <div class="btn-group" style="margin-top:-9px;">
                供应商编码<br /><input id="UnitNO" name="UnitNO" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                供应商全称<br /><input id="UnitFullName" name="UnitFullName" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="margin-top:-9px;">
                供应商简称<br /><input id="UnitShortName" name="UnitShortName" type="text" class="form-control" /> &nbsp;
            </div>
            <div class="btn-group" style="">
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span> 检索</a>
            </div>
            <div class="btn-group" style="float:right;">
                <a id="" class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span> 刷新</a>
                <a id="btn_add" class="btn btn-primary center-block" onclick="btn_add()"><span class="glyphicon glyphicon-plus"></span> 新增</a>
                <a id="btn_remove" class="btn btn-primary center-block disabled" onclick="btn_remove()"><span class="glyphicon glyphicon-trash"></span> 删除</a>
                <a id="btn_edit" class="btn btn-primary center-block disabled" onclick="btn_edit()"><span class="glyphicon glyphicon-edit"></span> 修改</a>
                <a id="btn_export" class="btn btn-primary center-block" onclick="btn_export()"><span class="glyphicon glyphicon-download"></span> 导出</a>
            </div>
        </div>
    </form>
    <div style="">
        <table id="gridList"></table>
        <div id="gridPager"></div>
    </div>
</div>

